package com.book.util;

import javax.servlet.http.HttpServletRequest;

public class RequestURL {
	public static String getRequestURL(HttpServletRequest request) { 
		if (request == null) { 
		return " "; 
		} 

		String url = " "; 
		url = request.getContextPath(); 
		url = url + request.getServletPath(); 

		java.util.Enumeration names = request.getParameterNames(); 
		int i = 0; 
		// String requestPageUrl = " "; 
		if (names != null) { 
		while (names.hasMoreElements()) { 
		String name = (String) names.nextElement(); 
		if (name.equals( "requestPageUrl ") || name.indexOf( "log ") != -1) { 
		// requestPageUrl = request.getParameter(name); 
		continue; 
		} 

		if (i == 0) { 
		url = url + "? "; 
		} 
		else { 
		url = url + "& "; 
		} 
		i++; 

		String value = request.getParameter(name); 
		if (value == null) { 
		value = " "; 
		} 

		url = url + name + "= " + value; 
		} 
		} 

		try { 
		java.net.URLEncoder.encode(url, "ISO-8859 "); 
		} 
		catch (Exception e) { 

		} 
		return url; 
		} 
}
